package com.itheima.service.impl;

import com.itheima.entity.ActHiActinst;
import com.itheima.dao.ActHiActinstDao;
import com.itheima.service.ActHiActinstService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (ActHiActinst)表服务实现类
 *
 * @author makejava
 * @since 2022-01-16 15:48:50
 */
@Service("actHiActinstService")
public class ActHiActinstServiceImpl implements ActHiActinstService {
    @Resource
    private ActHiActinstDao actHiActinstDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id_ 主键
     * @return 实例对象
     */
    @Override
    public ActHiActinst queryById(String id_) {
        return this.actHiActinstDao.queryById(id_);
    }

    /**
     * 分页查询
     *
     * @param actHiActinst 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<ActHiActinst> queryByPage(ActHiActinst actHiActinst, PageRequest pageRequest) {
        long total = this.actHiActinstDao.count(actHiActinst);
        return new PageImpl<>(this.actHiActinstDao.queryAllByLimit(actHiActinst, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param actHiActinst 实例对象
     * @return 实例对象
     */
    @Override
    public ActHiActinst insert(ActHiActinst actHiActinst) {
        this.actHiActinstDao.insert(actHiActinst);
        return actHiActinst;
    }

    /**
     * 修改数据
     *
     * @param actHiActinst 实例对象
     * @return 实例对象
     */
    @Override
    public ActHiActinst update(ActHiActinst actHiActinst) {
        this.actHiActinstDao.update(actHiActinst);
        return this.queryById(actHiActinst.getId_());
    }

    /**
     * 通过主键删除数据
     *
     * @param id_ 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id_) {
        return this.actHiActinstDao.deleteById(id_) > 0;
    }
}
